# ImmutableHashSet

struct ImmutableHashSet (

) {

}

A disabled default is present on this object. To use it, use one of the other constructors or a factory function.

- this
this`(const T[] values)`

Constructs an immutable hash set from the given values. The values must
not have any duplicates.

A destructor is present on this object, but not explicitly documented in the source.

- this(this)
@disable this(this)

Copying this object is disabled.

- contains
`bool` contains`(T value)`

- opSlice
`immutable(T)[]` opSlice`()`

- empty
`bool` empty;

True if the set is empty.

- length
`size_t` length;

The number of items in the set.

1 auto ihs1 = immutable ImmutableHashSet!(int, a => a)([1, 3, 5, 19, 31, 40, 17]);
2 assert (ihs1.contains(1));
3 assert (ihs1.contains(3));
4 assert (ihs1.contains(5));
5 assert (ihs1.contains(19));
6 assert (ihs1.contains(31));
7 assert (ihs1.contains(40));
8 assert (ihs1.contains(17));
9 assert (!ihs1.contains(100));
10 assert (ihs1[].length == 7);
11
12 auto ihs2 = immutable ImmutableHashSet!(int, a => a)([]);
13 assert (ihs2.length == 0);
14 assert (ihs2.empty);
15 assert (ihs2[].length == 0);
16 assert (!ihs2.contains(42));

The immutable hash set is useful for constructing a read-only collection that supports quickly determining if an element is present.

Because the set does not support inserting, it only takes up as much memory as is necessary to contain the elements provided at construction. Memory is managed my malloc/free.